package com.agv.backend.mapper;


import com.agv.backend.entity.pojo.AgvFlaw;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AgvFlawMapper extends BaseMapper<AgvFlaw> {
    /**
     * 查询指定任务最新轮次的缺陷数据
     *
     * @param id 指定任务ID
     * @return 缺陷数据集合
     */
    @Select("SELECT * FROM agv_flaw WHERE task_id = #{id} AND delete_flag = false")
    List<AgvFlaw> getLiveInfo(@Param("id") Long id);

    /**
     * 检查指定任务ID的故障是否都已经确认完毕
     *
     * @param id 指定任务ID
     * @return 未确认数量
     */
    @Select("SELECT count( * ) FROM agv_flaw WHERE task_id = #{id} AND delete_flag = false AND confirmed IS NULL")
    int checkAllConfirmed(@Param("id") Long id);
}
